home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today - The Disc! 5
/
CD-ROM Today - The Disc (Issue 5)(November 1994).ISO
/
mac
/
Mac shareware
/
Education
/
RLaB
/
examples
/
contour.r
< prev
next >
Wrap
Text File
|
1994-09-21
|
783b
|
50 lines
#
# Simple contour plotting demonstration
#
NX = 20;
NY = 20;
xx = zeros (1, NX);
yy = zeros (1, NY);
for (i in 1:NX) { xx[i] = (i - NX/2)/(NX/2); }
for (i in 1:NY) { yy[i] = (i - NY/2)/(NY/2); }
zz = zeros (NX, NY);
for (i in 1:NX)
{
for (j in 1:NY)
{
r = sqrt (xx[i]^2 + yy[j]^2);
zz[i;j] = exp (-r * r) * cos (2*pi*r);
}
}
# Sin - Cos surface
x1 = -3:3:.2;
y1 = -3:3:.2;
z1 = zeros (x1.n, y1.n);
for (i in 1:x1.n)
{
for(j in 1:y1.n)
{
z1[i;j] = sin(y1[j]) * cos(x1[i]);
}
}
# Now create some plots
xlabel("X-Axis");
ylabel("Y-Axis");
ptitle ("Contour Demonstration");
plmesh (<< x = xx; y = yy; z = zz>>);
pause();
plcont (<< x = xx; y = yy; z = zz>>);
pause();
plmesh (<< x = x1; y = y1; z = z1>>);
pause();
plcont (<< x = x1; y = y1; z = z1>>);